<?php

  session_start();
  include "config.php";
  include "ALcustomer.php";

  if(isset($_SESSION["user"]))
  {
    include "$header";
    include "$body";
?>

<div style="position:absolute; top:0px; left:1px; border:0;">
  <span class="prevPage">Change Customer Details:Search > </span>
  <span class="prevPage">Record Details > </span>
  <span class="page">Confirm Details</span>
</div>

<?php

  include "$H_ccd";

  $title = ltrim($_SESSION["new_title"]);
  switch ($title)
  {
         case "0": $titlen = "Mr"; break;
         case "1": $titlen = "Miss"; break;
         case "2": $titlen = "Mrs"; break;
         case "3": $titlen = "Ms"; break;
  }
  $surname = ltrim($_SESSION["new_surname"]);
  $given_name = ltrim($_SESSION["new_given_name"]);
  $dob_day = ltrim($_SESSION["new_dob_day"]);
  $dob_month = ltrim($_SESSION["new_dob_month"]);
  switch ($dob_month)
  {
         case "01": $dob_monthn = "January"; break;
         case "02": $dob_monthn = "February"; break;
         case "03": $dob_monthn = "March"; break;
         case "04": $dob_monthn = "April"; break;
         case "05": $dob_monthn = "May"; break;
         case "06": $dob_monthn = "June"; break;
         case "07": $dob_monthn = "July"; break;
         case "08": $dob_monthn = "August"; break;
         case "09": $dob_monthn = "September"; break;
         case "10": $dob_monthn = "October"; break;
         case "11": $dob_monthn = "November"; break;
         case "12": $dob_monthn = "December"; break;
  }
  $dob_year = ltrim($_SESSION["new_dob_year"]);
  $address = ltrim($_SESSION["new_address"]);
  $post_code = ltrim($_SESSION["new_post_code"]);
  $ph_area1 = ltrim($_SESSION["new_ph_area1"]);
  $ph_no1 = ltrim($_SESSION["new_ph_no1"]);
  $ph_area2 = ltrim($_SESSION["new_ph_area2"]);
  $ph_no2 = ltrim($_SESSION["new_ph_no2"]);
  $card_type1 = ltrim($_SESSION["new_card_type1"]);
  switch ($card_type1)
  {
         case "0": $card_type1n = "Mastercard"; break;
         case "1": $card_type1n = "Visa"; break;
         case "2": $card_type1n = "Amex"; break;
         case "3": $card_type1n = "Diners Club"; break;
  }
  $card_name1 = ltrim($_SESSION["new_card_name1"]);
  $card_no1_1 = ltrim($_SESSION["new_card_no1_1"]);
  $card_no1_2 = ltrim($_SESSION["new_card_no1_2"]);
  $card_no1_3 = ltrim($_SESSION["new_card_no1_3"]);
  $card_no1_4 = ltrim($_SESSION["new_card_no1_4"]);
  $card_expiry_month1 = ltrim($_SESSION["new_card_expiry_month1"]);
  switch ($card_expiry_month1)
  {
         case "01": $card_expiry_month1n = "January"; break;
         case "02": $card_expiry_month1n = "February"; break;
         case "03": $card_expiry_month1n = "March"; break;
         case "04": $card_expiry_month1n = "April"; break;
         case "05": $card_expiry_month1n = "May"; break;
         case "06": $card_expiry_month1n = "June"; break;
         case "07": $card_expiry_month1n = "July"; break;
         case "08": $card_expiry_month1n = "August"; break;
         case "09": $card_expiry_month1n = "September"; break;
         case "10": $card_expiry_month1n = "October"; break;
         case "11": $card_expiry_month1n = "November"; break;
         case "12": $card_expiry_month1n = "December"; break;
  }
  $card_expiry_year1 = ltrim($_SESSION["new_card_expiry_year1"]);
  $card_type2 = ltrim($_SESSION["new_card_type2"]);
  switch ($card_type2)
  {
         case "0": $card_type2n = "Mastercard"; break;
         case "1": $card_type2n = "Visa"; break;
         case "2": $card_type2n = "Amex"; break;
         case "3": $card_type2n = "Diners Club"; break;
  }
  $card_name2 = ltrim($_SESSION["new_card_name2"]);
  $card_no2_1 = ltrim($_SESSION["new_card_no2_1"]);
  $card_no2_2 = ltrim($_SESSION["new_card_no2_2"]);
  $card_no2_3 = ltrim($_SESSION["new_card_no2_3"]);
  $card_no2_4 = ltrim($_SESSION["new_card_no2_4"]);
  $card_expiry_month2 = ltrim($_SESSION["new_card_expiry_month2"]);
  switch ($card_expiry_month2)
  {
         case "01": $card_expiry_month2n = "January"; break;
         case "02": $card_expiry_month2n = "February"; break;
         case "03": $card_expiry_month2n = "March"; break;
         case "04": $card_expiry_month2n = "April"; break;
         case "05": $card_expiry_month2n = "May"; break;
         case "06": $card_expiry_month2n = "June"; break;
         case "07": $card_expiry_month2n = "July"; break;
         case "08": $card_expiry_month2n = "August"; break;
         case "09": $card_expiry_month2n = "September"; break;
         case "10": $card_expiry_month2n = "October"; break;
         case "11": $card_expiry_month2n = "November"; break;
         case "12": $card_expiry_month2n = "December"; break;
  }
  $card_expiry_year2 = ltrim($_SESSION["new_card_expiry_year2"]);


  if($titlen == "")
  {
      $titlen = $_SESSION["old_title"];
  }
  if($surname == "")
  {
      $surname = $_SESSION["old_surname"];
  }
  if($given_name == "")
  {
      $given_name = $_SESSION["old_given_name"];
  }
  if($dob_day == "")
  {
      $dob_day = $_SESSION["old_dob_day"];
  }
  if($dob_monthn == "")
  {
      $dob_month = $_SESSION["old_dob_month"];
      switch ($dob_month)
      {
             case "01": $dob_monthn = "January"; break;
             case "02": $dob_monthn = "February"; break;
             case "03": $dob_monthn = "March"; break;
             case "04": $dob_monthn = "April"; break;
             case "05": $dob_monthn = "May"; break;
             case "06": $dob_monthn = "June"; break;
             case "07": $dob_monthn = "July"; break;
             case "08": $dob_monthn = "August"; break;
             case "09": $dob_monthn = "September"; break;
             case "10": $dob_monthn = "October"; break;
             case "11": $dob_monthn = "November"; break;
             case "12": $dob_monthn = "December"; break;
             }
  }
  if($dob_year == "")
  {
      $dob_year = $_SESSION["old_dob_year"];
  }
  if($address == "")
  {
      $address = $_SESSION["old_address"];
  }
  if($post_code == "")
  {
      $post_code = $_SESSION["old_post_code"];
  }
  if($ph_area1 == "")
  {
      $ph_area1 = $_SESSION["old_ph_area1"];
  }
  if($ph_no1 == "")
  {
      $ph_no1 = $_SESSION["old_ph_no1"];
  }
  if($ph_area2 == "")
  {
      $ph_area2 = $_SESSION["old_ph_area2"];
  }
  if($ph_no2 == "")
  {
      $ph_no2 = $_SESSION["old_ph_no2"];
  }
  if($card_type1 == "")
  {
      $card_type1n = $_SESSION["old_card_type1"];
  }
  if($card_name1 == "")
  {
      $card_name1 = $_SESSION["old_card_name1"];
  }
  if($card_no1_1 == "")
  {
      $card_no1_1 = $_SESSION["old_card_no1_1"];
  }
  if($card_no1_2 == "")
  {
      $card_no1_2 = $_SESSION["old_card_no1_2"];
  }
  if($card_no1_3 == "")
  {
      $card_no1_3 = $_SESSION["old_card_no1_3"];
  }
  if($card_no1_4 == "")
  {
      $card_no1_4 = $_SESSION["old_card_no1_4"];
  }
  if($card_expiry_month1n == "")
  {
      $card_expiry_month1 = $_SESSION["old_card_expiry_month1"];
      switch ($card_expiry_month1)
      {
             case "01": $card_expiry_month1n = "January"; break;
             case "02": $card_expiry_month1n = "February"; break;
             case "03": $card_expiry_month1n = "March"; break;
             case "04": $card_expiry_month1n = "April"; break;
             case "05": $card_expiry_month1n = "May"; break;
             case "06": $card_expiry_month1n = "June"; break;
             case "07": $card_expiry_month1n = "July"; break;
             case "08": $card_expiry_month1n = "August"; break;
             case "09": $card_expiry_month1n = "September"; break;
             case "10": $card_expiry_month1n = "October"; break;
             case "11": $card_expiry_month1n = "November"; break;
             case "12": $card_expiry_month1n = "December"; break;
             }
  }
  if($card_expiry_year1 == "")
  {
      $card_expiry_year1 = "20".$_SESSION["old_card_expiry_year1"];
  }
  if($card_type2 == "")
  {
      $card_type2n = $_SESSION["old_card_type2"];
  }
  if($card_name2 == "")
  {
      $card_name2 = $_SESSION["old_card_name2"];
  }
  if($card_no2_1 == "")
  {
      $card_no2_1 = $_SESSION["old_card_no2_1"];
  }
  if($card_no2_2 == "")
  {
      $card_no2_2 = $_SESSION["old_card_no2_2"];
  }
  if($card_no2_3 == "")
  {
      $card_no2_3 = $_SESSION["old_card_no2_3"];
  }
  if($card_no2_4 == "")
  {
      $card_no2_4 = $_SESSION["old_card_no2_4"];
  }
  if($card_expiry_month2n == "")
  {
      $card_expiry_month2 = $_SESSION["old_card_expiry_month2"];
      switch ($card_expiry_month2)
      {
             case "01": $card_expiry_month2n = "January"; break;
             case "02": $card_expiry_month2n = "February"; break;
             case "03": $card_expiry_month2n = "March"; break;
             case "04": $card_expiry_month2n = "April"; break;
             case "05": $card_expiry_month2n = "May"; break;
             case "06": $card_expiry_month2n = "June"; break;
             case "07": $card_expiry_month2n = "July"; break;
             case "08": $card_expiry_month2n = "August"; break;
             case "09": $card_expiry_month2n = "September"; break;
             case "10": $card_expiry_month2n = "October"; break;
             case "11": $card_expiry_month2n = "November"; break;
             case "12": $card_expiry_month2n = "December"; break;
             }
  }
  if($card_expiry_year2 == "")
  {
      $card_expiry_year2 = "20".$_SESSION["old_card_expiry_year2"];
  }

  if(isset($_GET["yes"]))
  {
       $dob = $dob_year."-".$dob_month."-".$dob_day;
       $phone1 = $ph_area1.$ph_no1;
       $phone2 = $ph_area2.$ph_no2;
       $card_no1 = $card_no1_1.$card_no1_2.$card_no1_3.$card_no1_4;
       $card_no2 = $card_no2_1.$card_no2_2.$card_no2_3.$card_no2_4;
       $card_expiry_date1 = $card_expiry_month1.substr($card_expiry_year1, 2);
       $card_expiry_date2 = $card_expiry_month2.substr($card_expiry_year2, 2);

       if(updateCustomerDetails($titlen, $surname, $given_name, $dob, $address, $post_code, $phone1, $phone2, $card_type1n, $card_name1, $card_no1, $card_expiry_date1, $card_type2n, $card_name2, $card_no2, $card_expiry_date2) == false)
       {
            echo "<SCRIPT language='Javascript'>";
            echo "  alert('The details could not be added.  Please try again.');";
            echo "</SCRIPT>";
       }
       else
       {
           echo "<SCRIPT language='Javascript'>";
           echo "  window.location.href = 'changeCustomerDetails_3success.php';";
           echo "</SCRIPT>";
       }
  }
  else if(isset($_GET["no"]))
  {
       echo "<SCRIPT language='Javascript'>";
       echo "  window.location.href = 'changeCustomerDetails_1recordDetails.php';";
       echo "</SCRIPT>";
  }

  echo "Changing details for Customer No. <b>".$_SESSION["customerID"]."</b><p>";

?>

<b>CONFIRMATION: ARE THESE DETAILS ACCURATE?</b>
<br>
( <font color="blue">Changed details</font> )
<p>

<form name="recordCustomer" action="" method="get">
      <table class="recordCustomer" width="90%" border="0" cellpadding="5" cellspacing="5">
             <tr>
                 <td width="30%" align="right">
                     <span class="style3"><b>Title</b><font color="red">*</font></span>
                 </td>
                 <td width="*" align="left">
                     <input class="recordCustomer" name="title" type=text style="border:1px solid #000000; width:50px; color:blue" readonly value="<?php echo $titlen; ?>">

                 </td>
             </tr>
             <tr>
                 <td width="36%" align="right">
                     <span class="style3"><b>Surname</b><font color="red">*</font></span>
                 </td>
                 <td width="64%" align="left">
                     <input class="recordCustomer" name="surname" type=text style="border:1px solid #000000; width:200px; color:blue" readonly value="<?php echo $surname; ?>"/>
                 </td>
             </tr>
             <tr>
                 <td align="right">
                     <span class="style3"><b>Given Name</b><font color="red">*</font></span>
                 </td>
                 <td width="64%" align="left">
                     <input class="recordCustomer" name="given_name" type=text style="border:1px solid #000000; width:200px; color:blue" readonly value="<?php echo $given_name; ?>"/>
                 </td>
             </tr>
             <tr>
                 <td align="right">
                     <span class="style3"><b>Date of Birth</b><font color="red">*</font></span>
                 </td>
                 <td width="64%" align="left">
                     <input class="recordCustomer" name="dob_day" style="border:1px solid #000000; width:50px; color:blue" readonly value="<?php echo $dob_day; ?>"/>
                     <input class="recordCustomer" name="dob_month" style="border:1px solid #000000; width:100px; color:blue" readonly value="<?php echo $dob_monthn; ?>"/>
                     <input class="recordCustomer" name="dob_year"  style="border:1px solid #000000; width:75px; color:blue" readonly value="<?php echo $dob_year; ?>"/>
                 </td>
             </tr>
             <tr>
                 <td align="right">
                     <span class="style3"><b>Address</b><font color="red">*</font></span>
                 </td>
                 <td width="64%" align="left">
                     <input type=text class="recordCustomer" name="address" style="border:1px solid #000000; width:200px; color:blue" readonly value="<?php echo $address; ?>"/>
                 </td>
             </tr>
             <tr>
                 <td align="right">
                     <span class="style3"><b>Post Code<font color="red">*</font></span>
                 </td>
                 <td width="64%" align="left">
                     <input class="recordCustomer" name="post_code" type=text style="border:1px solid #000000; width:50px; color:blue" readonly value="<?php echo $post_code; ?>"/>
                 </td>
             </tr>
             <tr>
                 <td align="right">
                     <span class="style3"><b>Phone (H)/(M)</b><font color="red">*</font><br/><b>(W)</b></span>
                 </td>
                 <td width="64%" align="left">
                     ( <input class="recordCustomer" name="ph_area1" type=text style="border:1px solid #000000; width:20px; color:blue" readonly value="<?php echo $ph_area1; ?>"/> )
                     <input class="recordCustomer" name="ph_no1" type=text style="border:1px solid #000000; width:155px; color:blue" readonly value="<?php echo $ph_no1; ?>"/><br />
                     ( <input class="recordCustomer" name="ph_area2" type=text style="border:1px solid #000000; width:20px; color:blue" readonly value="<?php echo $ph_area2; ?>"/> )
                     <input class="recordCustomer" name="ph_no2" type=text style="border:1px solid #000000; width:155px; color:blue" readonly value="<?php echo $ph_no2; ?>"/>
                 </td>
             </tr>
             <tr>
                 <td align="right" valign="top">
                     <span class="style3"><b>Preferred Credit Card</b><font color="red">*</font></span>
                 </td>
                 <td width="64%" align="left">
                     <table style="border:1px solid #000000">
                            <tr>
                                <td>
                                    <tr>
                                        <td>
                                            Card Type: &nbsp; <input class="recordCustomer" name="card_type1" style="border:1px solid #000000; width:100px; color:blue" readonly value="<?php echo $card_type1n; ?>"/>
                                        </td>
                                    </tr>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Card Name: &nbsp; <input class="recordCustomer" name="card_name1" type="text" style="border:1px solid black; width:150px; color:blue" readonly value="<?php echo $card_name1; ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Card Number: &nbsp; <input class="recordCustomer" name="card_no1_1" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no1_1; ?>"/>
                                    <input class="recordCustomer" name="card_no1_2" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no1_2; ?>">
                                    <input class="recordCustomer" name="card_no1_3" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no1_3; ?>">
                                    <input class="recordCustomer" name="card_no1_4" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no1_4; ?>">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Expiry Date: &nbsp; <input class="recordCustomer" name="card_expiry_month1" style="border:1px solid #000000; width:100px; color:blue" readonly value="<?php echo $card_expiry_month1n; ?>"/>
                                    <input class="recordCustomer" name="card_expiry_year1" style="border:1px solid #000000; width:75px; color:blue" readonly value="<?php echo $card_expiry_year1; ?>"/>
                                </td>
                            </tr>
                     </table>
                 </td>
             </tr>
                  <tr>
                      <td align="right" valign="top">
                          <span class="style3"><b>Alternate Credit Card</b></span>
                      </td>
                      <td width="64%" align="left">
                     <table style="border:1px solid #000000">
                            <tr>
                                <td>
                                    <tr>
                                        <td>
                                            Card Type: &nbsp; <input class="recordCustomer" name="card_type2" style="border:1px solid #000000; width:100px; color:blue" readonly value="<?php echo $card_type2n; ?>"/>
                                        </td>
                                    </tr>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Card Name: &nbsp; <input class="recordCustomer" name="card_name2" type="text" style="border:1px solid black; width:150px; color:blue" readonly value="<?php echo $card_name2; ?>">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Card Number: &nbsp; <input class="recordCustomer" name="card_no2_1" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no2_1; ?>">
                                    <input class="recordCustomer" name="card_no2_2" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no2_2; ?>">
                                    <input class="recordCustomer" name="card_no2_3" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no2_3; ?>">
                                    <input class="recordCustomer" name="card_no2_4" type="text" style="width:40px; color:blue" readonly value="<?php echo $card_no2_4; ?>">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Expiry Date: &nbsp; <input class="recordCustomer" name="card_expiry_month2" style="border:1px solid #000000; width:100px; color:blue" readonly value="<?php echo $card_expiry_month2n; ?>"/>
                                    <input class="recordCustomer" name="card_expiry_year2" style="border:1px solid #000000; width:75px; color:blue" readonly value="<?php echo $card_expiry_year2; ?>"/>
                                </td>
                            </tr>
                     </table>
                 </td>
             </tr>
      </table>
      <p>
      <input name="no" type=submit style="font-family:'Century Gothic'; font-size:12px; color:#000000; border:1px solid #000000; width:70px; background-color:#FFFFFF" value="No"/>&nbsp;&nbsp;
      <input name="yes" type=submit style="font-family:'Century Gothic'; font-size:12px; color:#000000; border:1px solid #000000; width:70px; background-color:#FFFFFF" value="Yes"/>
</form>
</BODY>

<?php

  include "$footer";

  echo "<SCRIPT language='Javascript'>";
  if($_SESSION["new_title"] == "")
  {
      echo "  recordCustomer.title.style.color='black';";
  }
  if($_SESSION["new_surname"] == "")
  {
      echo "  recordCustomer.surname.style.color='black';";
  }
  if($_SESSION["new_given_name"] == "")
  {
      echo "  recordCustomer.given_name.style.color='black';";
  }
  if($_SESSION["new_dob_day"] == "")
  {
      echo "  recordCustomer.dob_day.style.color='black';";
  }
  if($_SESSION["new_dob_month"] == "")
  {
      echo "  recordCustomer.dob_month.style.color='black';";
  }
  if($_SESSION["new_dob_year"] == "")
  {
      echo "  recordCustomer.dob_year.style.color='black';";
  }
  if($_SESSION["new_address"] == "")
  {
      echo "  recordCustomer.address.style.color='black';";
  }
  if($_SESSION["new_post_code"] == "")
  {
      echo "  recordCustomer.post_code.style.color='black';";
  }
  if($_SESSION["new_ph_area1"] == "")
  {
      echo "  recordCustomer.ph_area1.style.color='black';";
  }
  if($_SESSION["new_ph_no1"] == "")
  {
      echo "  recordCustomer.ph_no1.style.color='black';";
  }
  if($_SESSION["new_ph_area2"] == "")
  {
      echo "  recordCustomer.ph_area2.style.color='black';";
  }
  if($_SESSION["new_ph_no2"] == "")
  {
      echo "  recordCustomer.ph_no2.style.color='black';";
  }
  if($_SESSION["new_card_type1"] == "")
  {
      echo "  recordCustomer.card_type1.style.color='black';";
  }
  if($_SESSION["new_card_name1"] == "")
  {
      echo "  recordCustomer.card_name1.style.color='black';";
  }
  if($_SESSION["new_card_no1_1"] == "")
  {
      echo "  recordCustomer.card_no1_1.style.color='black';";
  }
  if($_SESSION["new_card_no1_2"] == "")
  {
      echo "  recordCustomer.card_no1_2.style.color='black';";
  }
  if($_SESSION["new_card_no1_3"] == "")
  {
      echo "  recordCustomer.card_no1_3.style.color='black';";
  }
  if($_SESSION["new_card_no1_4"] == "")
  {
      echo "  recordCustomer.card_no1_4.style.color='black';";
  }
  if($_SESSION["new_card_expiry_month1"] == "")
  {
      echo "  recordCustomer.card_expiry_month1.style.color='black';";
  }
  if($_SESSION["new_card_expiry_year1"] == "")
  {
      echo "  recordCustomer.card_expiry_year1.style.color='black';";
  }
  if($_SESSION["new_card_type2"] == "")
  {
      echo "  recordCustomer.card_type2.style.color='black';";
  }
  if($_SESSION["new_card_name2"] == "")
  {
      echo "  recordCustomer.card_name2.style.color='black';";
  }
  if($_SESSION["new_card_no2_1"] == "")
  {
      echo "  recordCustomer.card_no2_1.style.color='black';";
  }
  if($_SESSION["new_card_no2_2"] == "")
  {
      echo "  recordCustomer.card_no2_2.style.color='black';";
  }
  if($_SESSION["new_card_no2_3"] == "")
  {
      echo "  recordCustomer.card_no2_3.style.color='black';";
  }
  if($_SESSION["new_card_no2_4"] == "")
  {
      echo "  recordCustomer.card_no2_4.style.color='black';";
  }
  if($_SESSION["new_card_expiry_month2"] == "")
  {
      echo "  recordCustomer.card_expiry_month2.style.color='black';";
  }
  if($_SESSION["new_card_expiry_year2"] == "")
  {
      echo "  recordCustomer.card_expiry_year2.style.color='black';";
  }
  echo "</SCRIPT>";

  }

?>